﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;
using Microsoft.SmartDevice.Connectivity;

namespace RemoteToolApp
{
    public partial class DeviceInfo : Form
    {
        public Device device;

        public DeviceInfo(Device a)
        {
            device = a;
            InitializeComponent();
            ShowSystemInfo();
        }

        private void ShowSystemInfo()
        {
            //device.GetProperty;
 /*           string xml = @"<wap-provisioningdoc>
  <characteristic type=""SecurityPolicy"">
    <parm name=""4123"" value=""12"" />
    <parm name=""4122"" value=""46"" />
    <parm name=""4101"" value=""4"" />
    <parm name=""4102"" value=""10"" />
    <parm name=""4097"" value=""1"" />
  </characteristic>
</wap-provisioningdoc>";
            */
            


            textBox1.Text = "Name:  " + device.Name + "\r\n" + 
                            "Platform:  " + device.Platform + "\r\n"+ 
                            "ID:  " + device.Id.ToString() + "\r\n" + 
                            "Configuration:  "+ "\r\n";

            
            string xml = device.ProvisionDevice(@"<wap-provisioningdoc></wap-provisioningdoc>", Device.ConfigActions.ReadMetadata);
                            
            
                
            //add info about Device ID, name, properties, and get Config information.
            SystemInfo info = device.GetSystemInfo();
            
            textBox1.Text += "Total Page File:  " + info.TotalPageFile.ToString() + "\r\n";
            textBox1.Text += "Available Page File:  " + info.AvailPageFile.ToString() + "\r\n";
            textBox1.Text += "Page Size:  " + info.PageSize.ToString() + "\r\n\r\n";

            textBox1.Text += "Total RAM:  " + info.TotalPhys.ToString() + "\r\n";
            textBox1.Text += "Available RAM:  " + info.AvailPhys.ToString() + "\r\n\r\n";
            
            textBox1.Text += "Total Virtual Memory:  " + info.TotalVirtual.ToString() + "\r\n";
            textBox1.Text += "Available Virtual Memory:  " + info.AvailVirtual.ToString() + "\r\n\r\n";
            
            
            if (info.ACLineStatus==1)
            {
                textBox1.Text += "AC Line plugged in. \r\n";
            }
            else
            {
                textBox1.Text += "AC Line unplugged. \r\n";
            }
            if (info.BackupBatteryFlag==1)
            {
                textBox1.Text += "Backup battery: \r\n";         
                textBox1.Text += "   Capacity:  " + info.BackupBatteryFullLifetime.ToString() + "\r\n";
                textBox1.Text += "   Percent:  " + info.BackupBatteryLifePercent.ToString() + "\r\n";
                textBox1.Text += "   Life:  " + info.BackupBatteryLifetime.ToString() + "\r\n";                
            }
            if (info.BatteryFlag==1)
            {
                textBox1.Text += "Main Battery: \r\n";
                textBox1.Text += "   Capacity:  " + info.BatteryFullLifetime.ToString() + "\r\n";
                textBox1.Text += "   Percent:  " + info.BatteryLifePercent.ToString() + "\r\n";
                textBox1.Text += "   Life:  " + info.BatteryLifetime.ToString() + "\r\n";            
            }
            
            
            
            textBox1.Text += "Device Time:  " + info.CurrentTime.ToString() + "\r\n";
            
            
            textBox1.Text += "Processor Architecture:  " + info.ProcessorArchitecture.ToString() + "\r\n";
            textBox1.Text += "Instruction Set:  " + info.InstructionSet.ToString() + "\r\n";
            textBox1.Text += "Number of CPU:  " + info.NumberOfProcessors.ToString() + "\r\n";
            textBox1.Text += "OS:  " + info.OSMajor.ToString() + "." + info.OSMinor.ToString() + "." + info.OSBuildNo.ToString() + "\r\n";
            
            
            textBox1.Text += "Locale ID:  " + info.SystemDefaultLocaleId.ToString() + "\r\n";

            
            
        }
        
    }
}
